home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / program / gcc / ixemul-4.lha / ixemul-41.4 / include / machine / cpu.h < prev    next >
C/C++ Source or Header  |  1995-06-22  |  7KB  |  193 lines

  1. /*
  2.  * Copyright (c) 1988 University of Utah.
  3.  * Copyright (c) 1982, 1990 The Regents of the University of California.
  4.  * All rights reserved.
  5.  *
  6.  * This code is derived from software contributed to Berkeley by
  7.  * the Systems Programming Group of the University of Utah Computer
  8.  * Science Department.
  9.  *
  10.  * Redistribution and use in source and binary forms, with or without
  11.  * modification, are permitted provided that the following conditions
  12.  * are met:
  13.  * 1. Redistributions of source code must retain the above copyright
  14.  *    notice, this list of conditions and the following disclaimer.
  15.  * 2. Redistributions in binary form must reproduce the above copyright
  16.  *    notice, this list of conditions and the following disclaimer in the
  17.  *    documentation and/or other materials provided with the distribution.
  18.  * 3. All advertising materials mentioning features or use of this software
  19.  *    must display the following acknowledgement:
  20.  *    This product includes software developed by the University of
  21.  *    California, Berkeley and its contributors.
  22.  * 4. Neither the name of the University nor the names of its contributors
  23.  *    may be used to endorse or promote products derived from this software
  24.  *    without specific prior written permission.
  25.  *
  26.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  27.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  30.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  32.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  33.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  34.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  35.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  36.  * SUCH DAMAGE.
  37.  *
  38.  * from: Utah $Hdr: cpu.h 1.16 91/03/25$
  39.  *
  40.  *    @(#)cpu.h    7.7 (Berkeley) 6/27/91
  41.  */
  42.  
  43. /*
  44.  * Exported definitions unique to hp300/68k cpu support.
  45.  */
  46.  
  47. /*
  48.  * definitions of cpu-dependent requirements
  49.  * referenced in generic code
  50.  */
  51. #define    COPY_SIGCODE        /* copy sigcode above user stack in exec */
  52.  
  53. /*
  54.  * function vs. inline configuration;
  55.  * these are defined to get generic functions
  56.  * rather than inline or machine-dependent implementations
  57.  */
  58. #define    NEED_MINMAX        /* need {,i,l,ul}{min,max} functions */
  59. #undef    NEED_FFS        /* don't need ffs function */
  60. #undef    NEED_BCMP        /* don't need bcmp function */
  61. #undef    NEED_STRLEN        /* don't need strlen function */
  62.  
  63. #define    cpu_exec(p)    /* nothing */
  64. #define    cpu_wait(p)    /* nothing */
  65.  
  66. /*
  67.  * Arguments to hardclock, softclock and gatherstats
  68.  * encapsulate the previous machine state in an opaque
  69.  * clockframe; for amiga, use just what Exec
  70.  * leaves on the stack (not documented, thus private !!!)
  71.  */
  72. typedef struct intrframe {
  73.     int    exec_regs[6];
  74.     u_short    ps;
  75.     int    pc;
  76. } clockframe;
  77.  
  78. #define    CLKF_USERMODE(framep)    (((framep)->ps & PSL_S) == 0)
  79. #define    CLKF_BASEPRI(framep)    (((framep)->ps & PSL_IPL7) == 0)
  80. #define    CLKF_PC(framep)        ((framep)->pc)
  81.  
  82. #ifdef KERNEL
  83.  
  84. /*
  85.  * Preempt the current process if in interrupt from user mode,
  86.  * or after the current trap/syscall if in system mode.
  87.  */
  88. /* #define    need_resched()    { want_resched++; aston(); } */
  89. /* don't do anything on the Amiga, we don't use the BSD scheduler */
  90. #define need_resched() 
  91.  
  92. /*
  93.  * Give a profiling tick to the current process from the softclock
  94.  * interrupt.  On hp300, request an ast to send us through trap(),
  95.  * marking the proc as needing a profiling tick.
  96.  */
  97. /* #define    profile_tick(p, framep)    { (p)->p_flag |= SOWEUPC; aston(); } */
  98. static void inline 
  99. profile_tick (struct proc *p, clockframe *framep)
  100. {
  101.   if (p->p_stats->p_prof.pr_scale)
  102.     addupc (CLKF_PC(framep), &p->p_stats->p_prof, 1);
  103. }
  104.  
  105.  
  106. /*
  107.  * Notify the current process (p) that it has a signal pending,
  108.  * process as soon as possible.
  109.  *
  110.  * NOTE: this function assumes it is only called with p==curproc!!!
  111.  */
  112. static void inline
  113. signotify (struct proc *p)
  114. {
  115.   u_int sr, curr_disp;
  116.   /* NOTE: the context switch is done to make sure sig_launch() is called as
  117.    *       soon as possible in the respective task. It's not nice if you can
  118.    *       return from a kill() to yourself, before the signal handler had a
  119.    *       chance to react accordingly to the signal..
  120.    */
  121.   asm volatile (" 
  122.     movel a5,a0
  123. FIXME: It is uncertain if the below line needs to have the +2 removed or not.
  124. FIXME: It is also uncertain if this file is even used.  If so, this will error out.
  125.     lea      Lget_sr-.+2,a5 | Never used
  126.     movel 4:w,a6
  127.     jsr      a6@(-0x1e)
  128.     movel a1,%0
  129.     bra      Lskip
  130. Lget_sr:
  131.     movew sp@,a1    | get sr register from the calling function
  132.     rte
  133. Lskip:
  134.     movel a0,a5
  135.     " : "=g" (sr) : : "a0", "a1", "a6");
  136.  
  137.   if (sr & PSL_S) return; /* if in Supervisor, don't do this... */
  138.  
  139.   /* this quite brute-force method, but the only thing I could think of that
  140.    * really guarantees that there was a context switch..
  141.    * DispCount is the dispatch counter of Exec, thus we wait until there was
  142.    * at least one such dispatch ;-)
  143.    */
  144.   for (curr_disp = SysBase->DispCount; curr_disp == SysBase->DispCount; ) ;
  145. }
  146.  
  147.  
  148. /* what is this supposed to do? i.e. how is it different than startrtclock? */
  149. #define    enablertclock()
  150.  
  151. #endif    /* KERNEL */
  152.  
  153. /*
  154.  * 68851 and 68030 MMU
  155.  */
  156. #define    PMMU_LVLMASK    0x0007
  157. #define    PMMU_INV    0x0400
  158. #define    PMMU_WP        0x0800
  159. #define    PMMU_ALV    0x1000
  160. #define    PMMU_SO        0x2000
  161. #define    PMMU_LV        0x4000
  162. #define    PMMU_BE        0x8000
  163. #define    PMMU_FAULT    (PMMU_WP|PMMU_INV)
  164.  
  165. /* 680X0 function codes */
  166. #define    FC_USERD    1    /* user data space */
  167. #define    FC_USERP    2    /* user program space */
  168. #define    FC_PURGE    3    /* HPMMU: clear TLB entries */
  169. #define    FC_SUPERD    5    /* supervisor data space */
  170. #define    FC_SUPERP    6    /* supervisor program space */
  171. #define    FC_CPU        7    /* CPU space */
  172.  
  173. /* fields in the 68020 cache control register */
  174. #define    IC_ENABLE    0x0001    /* enable instruction cache */
  175. #define    IC_FREEZE    0x0002    /* freeze instruction cache */
  176. #define    IC_CE        0x0004    /* clear instruction cache entry */
  177. #define    IC_CLR        0x0008    /* clear entire instruction cache */
  178.  
  179. /* additional fields in the 68030 cache control register */
  180. #define    IC_BE        0x0010    /* instruction burst enable */
  181. #define    DC_ENABLE    0x0100    /* data cache enable */
  182. #define    DC_FREEZE    0x0200    /* data cache freeze */
  183. #define    DC_CE        0x0400    /* clear data cache entry */
  184. #define    DC_CLR        0x0800    /* clear entire data cache */
  185. #define    DC_BE        0x1000    /* data burst enable */
  186. #define    DC_WA        0x2000    /* write allocate */
  187.  
  188. #define    CACHE_ON    (DC_WA|DC_BE|DC_CLR|DC_ENABLE|IC_BE|IC_CLR|IC_ENABLE)
  189. #define    CACHE_OFF    (DC_CLR|IC_CLR)
  190. #define    CACHE_CLR    (CACHE_ON)
  191. #define    IC_CLEAR    (DC_WA|DC_BE|DC_ENABLE|IC_BE|IC_CLR|IC_ENABLE)
  192. #define    DC_CLEAR    (DC_WA|DC_BE|DC_CLR|DC_ENABLE|IC_BE|IC_ENABLE)
  193.